package com.xymtop.api.config;

import com.xymtop.api.interceptor.AdminInterCeptor;
import com.xymtop.api.interceptor.LoginInterCeptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import java.util.ArrayList;
import java.util.List;

/**
 * @ClassName : WebConfig
 * @Description : 拦截器配置
 * @Author : 肖叶茂
 * @Date: 2022/12/3  16:33
 */
@Configuration
public class WebConfig implements WebMvcConfigurer {

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        List<String> expath = new ArrayList<>();
        List<String> adminPath = new ArrayList<>();


        expath.add("/user/login");
        expath.add("/user/add");
        expath.add("/captcha/getCaptcha");
        expath.add("/captcha/getEmailCaptcha");


        adminPath.add("/user/delete");


//        配置用户登录拦截器
        registry.addInterceptor(new LoginInterCeptor()).excludePathPatterns(expath).addPathPatterns();
        registry.addInterceptor(new AdminInterCeptor()).addPathPatterns(adminPath);
    }
}

